//
//  ZLInfoManager.m
//  ZLExamination
//
//  Created by Zheng on 2017/9/8.
//  Copyright © 2017年 Zheng. All rights reserved.
//

#import "ZLInfoManager.h"

static NSString *kStudentAccessToken = @"kStudentAccessToken";
static NSString *kAdminAccessToken = @"kAdminAccessToken";

@implementation ZLInfoManager

+ (void)initialize {
    [ZLInfoManager sharedManager];
}

+ (instancetype)sharedManager {
    static ZLInfoManager *manager = nil;
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        manager = [[ZLInfoManager alloc] init];
    });
    return manager;
}

- (instancetype)init {
    self = [super init];
    if (self) {
        _adminAccessToken = [[NSUserDefaults standardUserDefaults] objectForKey:kAdminAccessToken];
        _studentAccessToken = [[NSUserDefaults standardUserDefaults] objectForKey:kStudentAccessToken];
    }
    return self;
}

- (void)setStudentAccessToken:(NSString *)token {
    _studentAccessToken = token;
    [[NSUserDefaults standardUserDefaults] setObject:_studentAccessToken forKey:kStudentAccessToken];
}

- (void)removeStudentAccessToken {
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:kStudentAccessToken];
    _studentAccessToken = nil;
}

- (void)setAdminAccessToken:(NSString *)token {
    _adminAccessToken = token;
    [[NSUserDefaults standardUserDefaults] setObject:_adminAccessToken forKey:kAdminAccessToken];
}

- (void)removeAdminAccessToken {
    [[NSUserDefaults standardUserDefaults] removeObjectForKey:kAdminAccessToken];
    _adminAccessToken = nil;
}



@end
